From 3aff1296e36d47ca493d2d0b16d38871beaa37d2 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Thu, 7 Dec 2017 12:29:25 -0700 Subject: [PATCH] improve js debug & cleanup unused map stuff. --- gui/map.cc | 76 +++++++++++++++++++++--------------------------------- gui/map.h | 8 ++++++ 2 files changed, 37 insertions(+), 47 deletions(-) diff --git a/gui/map.cc b/gui/map.cc index e4d3c1e76..9bed4a32f 100644 --- a/gui/map.cc +++ b/gui/map.cc @@ -37,10 +37,15 @@ #include #include #include +#include #include +#include +#include #include "appname.h" -#include "dpencode.h" + +using std::string; +using std::vector; //------------------------------------------------------------------------ static QString stripDoubleQuotes(const QString s) { @@ -92,6 +97,14 @@ Map::Map(QWidget *parent, QString urlStr = "file:///" + baseFile; this->load(QUrl(urlStr)); } + +#ifdef DEBUG_JS_GENERATION + dbgdata_ = new QFile("mapdebug.js"); + if (dbgdata_->open(QFile::WriteOnly | QIODevice::Truncate)) { + dbgout_ = new QTextStream(dbgdata_); + } +#endif + } //------------------------------------------------------------------------ @@ -99,6 +112,16 @@ Map::~Map() { if (busyCursor_) QApplication::restoreOverrideCursor(); +#ifdef DEBUG_JS_GENERATION + if (dbgout_) { + delete dbgout_; + dbgout_ = NULL; + } + if (dbgdata_) { + delete dbgdata_; + dbgdata_ = NULL; + } +#endif } //------------------------------------------------------------------------ void Map::loadFinishedX(bool f) @@ -115,30 +138,6 @@ void Map::loadFinishedX(bool f) busyCursor_ = false; } -//------------------------------------------------------------------------ - -static QStringList makeLiteralVar(const QString &name, const string &s) -{ - QStringList out; - out << QString("var %1 = ").arg(name); - - QString ws = "\""; - for (unsigned int i=0; i 5120) { - ws += "\" + "; - out << ws; - ws = "\""; - } - } - ws += "\";"; - out << ws; - return out; -} - //------------------------------------------------------------------------ static QString fmtLatLng(const LatLng &l) { return QString("{lat: %1, lng: %3}").arg(l.lat(), 0, 'f', 5) .arg(l.lng(), 0, 'f', 5); @@ -155,11 +154,6 @@ void Map::showGpxData() connect(mclicker, SIGNAL(markerClicked(int, int )), this, SLOT(markerClicked(int, int))); connect(mclicker, SIGNAL(logTime(const QString &)), this, SLOT(logTime(const QString &))); #endif - // It is appreciably faster to do the encoding on the C++ side. - int numLevels = 18; - double zoomFactor = 2; - PolylineEncoder encoder(numLevels, zoomFactor, 0.00001); - this->logTime("Start defining JS string"); QStringList scriptStr; @@ -171,17 +165,7 @@ void Map::showGpxData() << "var rtes = [];" << "var trks = [];" << "var idx;" - << "//map.enableScrollWheelZoom();" - << "//map.enableContinuousZoom();" - << "//map.addControl(new GLargeMapControl());" - << "//map.addControl(new GScaleControl());" - << "//map.addControl(new GMapTypeControl());" - << "//var pn = map.getPane(G_MAP_MARKER_PANE);" - << "//pn.style.KhtmlUserSelect='none';" - << "//pn.style.KhtmlUserDrag='none';" << "mclicker.logTimeX(\"Done prelim JS definition\");" - << QString("var zoomFactor = %1;").arg(zoomFactor) - << QString("var numLevels = %1;").arg(numLevels) ; mapPresent_ = true; @@ -462,13 +446,11 @@ void Map::frameRoute(int i) //------------------------------------------------------------------------ void Map::evaluateJS(const QString &s, bool upd) { -QFile data("output.txt"); -if (data.open(QFile::WriteOnly | QIODevice::Append)) { - QTextStream out(&data); - out << s; - out << '\n'; -} -data.close(); +#ifdef DEBUG_JS_GENERATION + *dbgout_ << s; + *dbgout_ << '\n'; + dbgout_->flush(); +#endif #if HAVE_WEBENGINE this->page()->runJavaScript(s); #else diff --git a/gui/map.h b/gui/map.h index 20dd949aa..c25653f4c 100644 --- a/gui/map.h +++ b/gui/map.h @@ -29,8 +29,12 @@ #endif #include #include +#include +#include #include "gpx.h" +//#define DEBUG_JS_GENERATION + class QNetworkAccessManager; @@ -98,6 +102,10 @@ class Map : public QWebView void routeClicked(int i); private: +#ifdef DEBUG_JS_GENERATION + QFile *dbgdata_; + QTextStream *dbgout_; +#endif QNetworkAccessManager *manager_; const Gpx &gpx_; bool mapPresent_; -- 2.30.2